--
-- Author: yuyu
-- Date: 2019-02-27 16:11:09
--
-- PaynoticeView
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

local RewardFirstPayPanel = import(".RewardFirstPayPanel")
local RewardMonthlyPrivilege = import(".RewardMonthlyPrivilege")
local RewardFundPanel = import(".RewardFundPanel")

ClassRef.VIEW_ROOT_RES = Res.PayNoticeScene

function ClassRef:init()
    self._ui.Button_back:addClickEventListener(function()
        self:closeView()
    end)

    self._firstPayPanel = RewardFirstPayPanel.create(self._ui["Panel/recharge"]) --首充
    self._privilegePanel = RewardMonthlyPrivilege.create(self._ui["Panel/monthly"])  --特权礼包（月卡）
    self._fundPanel = RewardFundPanel.create(self._ui["Panel/fund"]) -- 抽奖基金

    self._firstPayPanel:setVisible(false)
    self._privilegePanel:setVisible(false)
    self._fundPanel:setVisible(false)
end

function ClassRef:refresh()
    if self._data then
        local data = self._data
        self._ui["Panel/Panel_tlt/Text_name"]:setString( L(data.name) )
        
        self.subType = data.subType
        if self.subType == Enums.ActivitySubType.FirstRecharge then
            self._firstPayPanel:onOperate(self._onOperate)
        elseif self.subType == Enums.ActivitySubType.Privilege then
            self._privilegePanel:onOperate(self._onOperate)
        elseif self.subType == Enums.ActivitySubType.Fund then
            self._fundPanel:onOperate(self._onOperate)
        end
        executeFunc(self._onOperate, "selectWelfare", data)
    end
end

function ClassRef:show(info, flag)
    if info then
        self._data = info
        self:refresh()
    end
    self.firstFlag = flag
end

function ClassRef:refreshCurrentPanel(data)
    if self.subType == Enums.ActivitySubType.FirstRecharge then
        self._firstPayPanel:setData(data)
        self._firstPayPanel:setVisible(true)
    elseif self.subType == Enums.ActivitySubType.Privilege then
        self._privilegePanel:setData(data)
        self._privilegePanel:setVisible(true)
    elseif self.subType == Enums.ActivitySubType.Fund then
        self._fundPanel:setData(data)
        self._fundPanel:setMoneyPanelState(false)
        self._fundPanel:setVisible(true)
    end
end

return ClassRef
